package java8;

import java.text.ParseException;

import timeDemo.TimeUtils;

/**
* @author jie
* @version 创建时间：2018年8月16日 下午1:10:39
* 类说明
*/
public class math {
	public static void main(String[] args) throws ParseException {

		long time3 = TimeUtils.ConvertDateToLong("2018-8-16 13:01:02");
		long time2 = TimeUtils.ConvertDateToLong("2018-8-16 11:30:55");
		long time1 = TimeUtils.ConvertDateToLong("2018-8-16 11:14:31");

		long tcp_snd1 = 67174977L;
		long tcp_rec1 = 696023L;
		long tcp_snd2 = 67211755L;
		long tcp_rec2 = 726425L;
		long tcp_snd3 = 67412629L;
		long tcp_rec3 = 897097L;
		TcpFlow tcpFlow1 = new TcpFlow(time1, tcp_snd1, tcp_rec1);
		TcpFlow tcpFlow2 = new TcpFlow(time2, tcp_snd2, tcp_rec2);
		TcpFlow tcpFlow3 = new TcpFlow(time3, tcp_snd3, tcp_rec3);
		TcpFlow tcpFlow4 = new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 13:39:45"), 67499662L, 968900L);
		//other 桌面级
		TcpFlow tcpFlow5 = new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 14:02:48"), 10513L, 15773L);
		TcpFlow tcpFlow6 = new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 14:06:22"), 11810L, 17116L);

//		mathFlowByteSecond(tcpFlow5, tcpFlow6);
//		mathFlowByteSecond(tcpFlow3, tcpFlow4);
//		mathFlowByteSecond(tcpFlow1, tcpFlow2);
		mathFlowByteSecond(tcpFlow1, tcpFlow3);

//		mathFlowByteSecond(
//				new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 10:45:00"), 14246271L, 486346L),
//				new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 13:13:00"), 14312210L, 547659L));
//		mathFlowByteSecond(
//								new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 13:13:00"), 14312210L, 547659L),
//								new TcpFlow(TimeUtils.ConvertDateToLong("2018-8-16 13:40:00"), 14324709L, 557331L));
	}

	private static void mathFlowByteSecond(TcpFlow tcpFlowBefore, TcpFlow tcpFlowAfter) {
		System.out.println("tcp send byte/s=="
				+ (tcpFlowAfter.tcp_snd - tcpFlowBefore.tcp_snd) / ((tcpFlowAfter.time - tcpFlowBefore.time) / 1000));
		System.out.println("tcp rece byte/s=="
				+ (tcpFlowAfter.tcp_rec - tcpFlowBefore.tcp_rec) / ((tcpFlowAfter.time - tcpFlowBefore.time) / 1000));

	}

}

class TcpFlow {
	long time;
	long tcp_snd;
	long tcp_rec;

	public TcpFlow(long time, long tcp_snd, long tcp_rec) {
		super();
		this.time = time;
		this.tcp_snd = tcp_snd;
		this.tcp_rec = tcp_rec;
	}

}
